<template>
  <div class="bottomLeft">
    <div class="bg-color-black">
      <div class="box-title">
        <img :src="img" class="title-img" style="height: 16px" alt="" />
        岗位需求前TOP8
      </div>
      <div class="box-all">
        <div class="box-list" v-for="(item, index) in list" :key="index">
          <div class="list-tips">{{ item.name }}</div>
          <div class="list-line">
            <el-slider v-model="item.number" :max="maxNum" :disabled="true" />
            <div
              class="line-num"
              :style="{ left: `${(item.number / maxNum) * 100 + 4}%` }"
            >
              {{item.number}} 个
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, reactive, onMounted, defineProps, watch } from "vue";
import { getTopEight } from "@/api/dataView"

// 定义 ref
const props = defineProps(['selectId']);
const img = ref(require("@/assets/three.png"));
const value1 = ref(20);
const list = ref([
  
]);
const maxNum = ref(0)

watch(()=>props.selectId, (newVal)=>{
  if(props.selectId || props.selectId == 0) {
    inintData(newVal)
  }
},{
  immediate: true,
  deep: true
})

async function inintData(id) {
  maxNum.value = 0
  const res = await getTopEight(id)
  res.data.forEach((item)=>{
    if(item.number > maxNum.value) {
      maxNum.value = item.number
    }
  }) 
   maxNum.value =  maxNum.value *1.2
  list.value = res.data
  // console.log('res', res)
}

onMounted(() => {
  // inintData();
});
</script>

<style lang="scss" scoped>
$box-height: 460px;
$box-width: 100%;
.bottomLeft {
  padding: 20px 16px;
  height: $box-height;
  width: $box-width;
  border-radius: 5px;
  .bg-color-black {
    height: $box-height - 35px;
    border-radius: 10px;
  }
  .text {
    color: #c3cbde;
    font-size: 20px;
  }
  .box-title {
    height: 40px;
    margin-bottom: 10px;
    border-left: 5px solid #409eff;
    background-color: #081f43;
    padding-left: 25px;
    box-sizing: border-box;
    position: relative;
    line-height: 40px;
    .title-img {
      position: absolute;
      left: 6px;
      top: 12px;
    }
  }
  .chart-box {
    margin-top: 16px;
    width: 170px;
    height: 170px;
    .active-ring-name {
      padding-top: 10px;
    }
  }
  .box-all::-webkit-scrollbar{
     width: 0px;
  }
  .box-all {
    max-height: 380px;
    overflow-y: scroll;
    .box-list {
      .list-tips {
      }
      .list-line {
        position: relative;
        .line-num {
          position: absolute;
          margin: auto;
          top: 0;
          bottom: 0;
          line-height: 32px;
          font-size: 12px;
        }
      }
    }
  }
}
:deep(.el-slider__bar) {
  background-image: linear-gradient(to right, #091a39, #2071d5);
}
:deep(.el-tooltip__trigger) {
  border-radius: 50% !important;
  padding: 7px !important;
  background-color: white !important;
  box-sizing: border-box !important;
}
:deep(.el-slider__button) {
  background-color: white !important;
}
:deep(.el-slider__runway) {
  background-color: transparent;
}
</style>
